package main

import "fmt"

// Animal 声明动物类型
type Animal struct {
	Name string
}

// 针对Animal的方法接受器
func (animal *Animal) sleep() {
	fmt.Println(animal.Name + "is sleeping...")
}

// Dog 声明小狗类型
type Dog struct {
	*Animal
}

// Cat 声明小猫类型
type Cat struct {
	*Animal
}

func main() {
	var dog = Dog{&Animal{Name: "旺旺"}}
	dog.sleep()
	var cat = Cat{&Animal{Name: "喵喵"}}
	cat.sleep()
}
